package com.goldenautumn.prefabricate.activity.search

import android.content.Context
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.DataBindingHolder
import com.goldenautumn.prefabricate.R
import com.goldenautumn.prefabricate.databinding.ItemHotSearchBinding

class HotSearchAdapter : BaseQuickAdapter<String, DataBindingHolder<ItemHotSearchBinding>>() {

    override fun onBindViewHolder(holder: DataBindingHolder<ItemHotSearchBinding>, position: Int, item: String?) {
        if(item == null) return
        var mBinding  = holder.binding
        if(position == 1 || position == 0) {
            mBinding.content.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(context, R.mipmap.ic_search_hot),null, null, null)
        } else {
            mBinding.content.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null)
        }
    }

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): DataBindingHolder<ItemHotSearchBinding> {
        return DataBindingHolder(R.layout.item_hot_search,parent)
    }

}